﻿<!--#include file="include/config.asp"-->
<!--#include file="include/conn_f.asp"-->
<!--#include file="include/syscode.asp"-->
<!--#include file="top.asp"-->
<!--#include file="left.asp"-->
<%
    If Session("cust_id") = vbNullString Then
        Response.Write("请先登录")
        Response.End()
    End If
    

    Dim gameCoinId, gCoinName, gameCoinUnit, gameCoinDisplayBuLuo
    gameCoinId = SafeRequest("gameCoinId", 1)
    gCoinName = gameCoinName(gameCoinId)
%>
<div class="content">
    <link href="css/css.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .STYLE1
        {
            color: #FF0000;
            font-size: 14px;
        }
        .red
        {
            color: #ff0000;
        }
    </style>
    <script language="javascript" type="text/javascript">

//二级联动菜单
var subcat = new Array();
<%
//值显示方式：root值Id、subRoot值、subRoot值Id
sql="select gameCoinDistrictId,gameCoinServerId,gameCoinServerName from gameCoinServer where isShow=1 order by gameCoinServerName"
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.open sql,conn,1,1
Dim n
n=0
Do While Not rs.eof
    %>
    subcat[<%=n%>] = new Array('<%=trim(rs("gameCoinDistrictId"))%>','<%=trim(rs("gameCoinServerName"))%>','<%=trim(rs("gameCoinServerId"))%>')
    <%
    rs.movenext
    n=n+1
Loop

%>

    function changeSelect(selectValue) {
        document.gameCoin.gameCoinServer.length = 0;
        document.gameCoin.gameCoinServer.options[0] = new Option('=服务器=', '');
        for (i = 0; i < subcat.length; i++) {
            if (subcat[i][0] == selectValue) {
                document.gameCoin.gameCoinServer.options[document.gameCoin.gameCoinServer.length] = new Option(subcat[i][1], subcat[i][2]);
            }
        }
    }

    //实时更新价格信息
//    var xmlHttp = false;
//    try {
//        xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
//    }
//    catch (e) {
//        try {
//            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
//        }
//        catch (e2) {
//            xmlHttp = false;
//        }
//    }

//    if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
//        xmlHttp = new XMLHttpRequest();
//    }

    function chkGameCoin(gameCoinId, gameCoinDisplayBuLuo) //检测游戏币服务器信息
    {

        var gameCoinDistrict = document.getElementById("gameCoinDistrict").value;
        var gameCoinServer = document.getElementById("gameCoinServer").value;
        var gameCoinQuantity = document.getElementById("gameCoinQuantity").value;
        var gameCoinDiv = 0;

        if (gameCoinDisplayBuLuo == "1") //show buluo
        {
            gameCoinDiv = document.getElementById("gameCoinDiv").value;
        }
        var url = "updatePrice.asp?gameCoinId=" + gameCoinId + "&gameCoinDistrictId=" + gameCoinDistrict + "&gameCoinServerId=" + gameCoinServer + "&gameCoinDivDisplay=" + gameCoinDisplayBuLuo + "&gameCoinDivId=" + gameCoinDiv + "&gameCoinQuantity=" + gameCoinQuantity;
        
//        xmlHttp.open("GET", url, true);
//        xmlHttp.onreadystatechange = updateGameCoinServer;
//        xmlHttp.send(null);

        $.get(url, updateGameCoinServer);
    }

    function updateGameCoinServer(data, textStatus, XMLHttpRequest) //更新价格
    {
        if (XMLHttpRequest.readyState < 4) {
            document.getElementById("singlePriceTip").innerHTML = "<font style='color:#ff0000;'>更新价格信息中...</font>";
            document.getElementById("totalPriceTip").innerHTML = "<font style='color:#ff0000;'>更新价格信息中...</font>";
        }
        if (XMLHttpRequest.readyState == 4) {

            var response = data.split("|"); // 返回数组
            document.getElementById("singlePriceTip").innerHTML = response[1];
            document.getElementById("totalPriceTip").innerHTML = response[3];
            document.getElementById("singlePrice").innerHTML = response[0];
            document.getElementById("totalPrice").innerHTML = response[2];
            document.getElementById("hiddenSinglePrice").value = response[4];
            document.getElementById("hiddenTotalPrice").value = response[7];
            //document.getElementById("stockTip").innerHTML=response[5];
            document.getElementById("gameCoinDiscountTip").innerHTML = response[5];
            document.getElementById("gameCoinPriceId").value = response[7];

        }
    }
    //
    function calculate() //计算总价格
    {
        var quantity = document.getElementById("gameCoinQuantity").value;
        var singlePrice = document.getElementById("hiddenSinglePrice").value;
        var totalPrice = quantity * singlePrice;
        document.getElementById("totalPrice").innerHTML = Math.round(totalPrice * 100) / 100;
    }
    //
    function itemReset() //选择游戏区时初始化
    {
        document.getElementById("singlePrice").innerHTML = "";
        document.getElementById("hiddenSinglePrice").value = "";
        document.getElementById("totalPrice").innerHTML = "";
        document.getElementById("hiddenTotalPrice").value = "";
        document.getElementById("singlePriceTip").innerHTML = "";
        document.getElementById("totalPriceTip").innerHTML = "";
    }
    </script>
    <script language="javascript">
        function formcheck() {
            if (document.getElementById("gameaccount")) {
                if (document.gameCoin.gameaccount.value.length < 1) {
                    alert("游戏角色名称没有填写!");
                    gameCoin.gameaccount.focus();
                    return (false);
                }
            }
        }
    </script>
    <br />
    <br />
    <form action="gamecoin2.asp" name="gameCoin" method="post" onsubmit="return formcheck()">
    <input type="hidden" name="hiddenSinglePrice" id="hiddenSinglePrice" value="">
    <input type="hidden" name="hiddenTotalPrice" id="hiddenTotalPrice" value="">
    <input type="hidden" name="gameCoinId" id="gameCoinId" value="<%=gameCoinId%>">
    <input type="hidden" name="gameCoinPriceId" id="gameCoinPriceId" value="0">
    <%
    Dim tmp, gameCoinNames, descript, photo_filename
    
    Set tmp = Server.CreateObject("ADODB.RecordSet")
    tmp.open "select * from gameCoin where gameCoinId=" & CInt(gameCoinId), conn, 0, 1
    If Not tmp.eof Then
        gameCoinNames = tmp("gameCoinName")
        gameCoinUnit = tmp("gameCoinUnit")
        gameCoinDisplayBuLuo = tmp("gameCoinDisplayBuLuo")
        descript = tmp("descript")
        photo_filename = tmp("photo_filename")
    End If

    %>
    <table width="500" border="1" align="center" cellpadding="5" cellspacing="0" bordercolor="#cccccc"
        class="tableTop" style="border-collapse: collapse;">
        <tr>
            <td colspan="2" align="center" valign="middle">
                <img src="photo/<%=photo_filename%>" width="200" />
                <br />
                <span class="STYLE1">
                    <%=gameCoinNames%></span>
            </td>
        </tr>
        <tr>
            <td colspan="2" align="center" valign="middle">
                <%=descript%>
            </td>
        </tr>
        <tr>
            <td width="100" align="right" valign="middle">
                游戏服务器区：
            </td>
            <td valign="top">
                <%Call gameCoinDistrict(gameCoinId)%>
            </td>
        </tr>
        <tr>
            <td align="right" valign="middle">
                游戏服务器：
            </td>
            <td valign="top">
                <select name="gameCoinServer" id="gameCoinServer" onchange='chkGameCoin("<%=gameCoinId%>","<%=gameCoinDisplayBuLuo%>")'>
                    <option>--服务器--</option>
                </select>
            </td>
        </tr>
        <% Call showGameDiv(gameCoinId, gameCoinDisplayBuLuo) '显示游戏币部落/联盟 %>
        <tr>
            <td align="right" valign="middle">
                购买数量：
            </td>
            <td valign="top">
                <select name="gameCoinQuantity" id="gameCoinQuantity" onchange='chkGameCoin("<%=gameCoinId%>","<%=gameCoinDisplayBuLuo%>")'>
                    <%
                    sql = "select * from gameCoinQuantity where gameCoinId=" & CInt(gameCoinId) & " order by gameCoinQuantityValue"
                    Set tmp = conn.execute(sql)
                    Do While Not tmp.eof
                    %>
                    <option value="<%=tmp("gameCoinQuantityValue")%>">
                        <%=tmp("gameCoinQuantityValue")%>&nbsp;<%=quantityUnit%></option>
                    <%
                    tmp.movenext()
                    If tmp.eof Then Exit Do
                Loop
                Call close_rs(tmp)
                    %>
                </select>
                &nbsp;<span id="gameCoinDiscountTip" class="red"></span>
            </td>
        </tr>
        <td align="right" valign="middle">
            单价：
        </td>
        <td valign="top">
            <span id="singlePrice"></span>&nbsp;元/<%=gameCoinUnit%>&nbsp;<span id="singlePriceTip"
                class="red"></span>
        </td>
        </tr>
        <!--
  <tr>
    <td align="right" valign="middle">库存状况：</td>
    <td valign="top"><span id="stockTip" class="green"></span></td>
  </tr>
  -->
        <tr>
            <td align="right" valign="middle">
                总价：
            </td>
            <td valign="top">
                <span id="totalPrice"></span>&nbsp;<span id="totalPriceTip" class="red"></span>元
            </td>
        </tr>
        <tr>
            <td align="right" valign="middle">
                游戏角色名称：
            </td>
            <td valign="top">
                <input name="gameaccount">
            </td>
        </tr>
        <tr>
            <td align="right" valign="middle">
                备注：
            </td>
            <td valign="top">
                <textarea name="memo"></textarea>
            </td>
        </tr>
        <tr>
            <td align="right" valign="middle">
                &nbsp;
            </td>
            <td valign="top">
                <input type="submit" value="购买" />
            </td>
        </tr>
    </table>
    </form>
</div>
<!--#include file="bottom.asp"-->
